package com.example.tabbar.fragment

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.CheckBox
import com.example.tabbar.activity.TabarActivity
import com.example.tabbar.databinding.FragmentSetFileBinding
import com.example.tabbar.databinding.FragmentSetParameterBinding


class SetFileFragment : Fragment() {
    private var binding: FragmentSetFileBinding? = null
    private var isShow: CheckBox? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        arguments?.let {
        }
    }

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        binding = FragmentSetFileBinding.inflate(inflater, container, false)
        return binding!!.root
    }
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        isShow = binding?.maintainShow
        isShow?.setOnCheckedChangeListener { _, isChecked ->
            if (isChecked) {
                Log.d("isShow", "显示维护tab")
                // 通知Activity显示维护tab
                (activity as? TabarActivity)?.showMaintenanceTab(true)
            } else {
                Log.d("isShow", "隐藏维护tab")
                // 通知Activity隐藏维护tab
                (activity as? TabarActivity)?.showMaintenanceTab(false)
            }
        }
    }

    companion object {

        @JvmStatic
        fun newInstance() =
            SetFileFragment().apply {
                arguments = Bundle().apply {

                }
            }
    }
}